package com.leyuangame.core.controller.api.user;

import com.leyuangame.core.controller.bean.ResponseHandler.LeYuanResult;
import com.leyuangame.core.service.LoginService;
import com.leyuangame.utils.ExceptionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class LoginController {
    @Autowired
    private LoginService loginService;

    @PostMapping(value = "/rest/login",produces = "application/json")
    @ResponseBody
    public LeYuanResult login(String phone,String passwd,String code){
        try {
            return loginService.login(phone,passwd,code);
        }catch (Exception e){
            return new LeYuanResult().build(1,ExceptionUtil.getStackTrace(e));
        }
    }

    public LeYuanResult login2(String phone,String passwd,String code){
        try {
            return null;
        }catch (Exception e){
            return new LeYuanResult().build(1,ExceptionUtil.getStackTrace(e));
        }
    }
}
